package com.byxy.shop.dao.provider;

//import lombok.extern.slf4j.Slf4j;
//
//@Slf4j
public class GoodsInfoDaoProvider {

	public String findByCategroyIdAndKeyword(Integer goodsCategoryId,String keyword) {
		if(goodsCategoryId != null && keyword == null) {
			return "select * from tb_newbee_mall_goods_info where goods_category_id=#{goodsCategoryId }";
		}else if(goodsCategoryId == null && keyword != null) {
			return "select * from tb_newbee_mall_goods_info where goods_name like concat(#{keyword})";
		}else if(goodsCategoryId != null && keyword != null) {
			return "select * from tb_newbee_mall_goods_info where goods_category_id=#{goodsCategoryId } and goods_name like concat(#{keyword})";
		}else {
			return "select * from tb_newbee_mall_goods_info";
		}
	}
	
	public String countByCategroyIdAndKeyword(Integer goodsCategoryId,String keyword) {
		if(goodsCategoryId != null && keyword == null) {
			return "select count(*) from tb_newbee_mall_goods_info where goods_category_id=#{goodsCategoryId }";
		}else if(goodsCategoryId == null && keyword != null) {
			return "select count(*) from tb_newbee_mall_goods_info where goods_name like concat(#{keyword})";
		}else if(goodsCategoryId != null && keyword != null) {
			return "select count(*) from tb_newbee_mall_goods_info where goods_category_id=#{goodsCategoryId } and goods_name like concat(#{keyword})";
		}else {
			return "select count(*) from tb_newbee_mall_goods_info";
		}
	}
}
